Skip to main content

Android Firebase Configration

Setting up Firebase for your HandyHue App Project with Android.

Add Android App With The Package Name In Firebase Console:

  1. On the Firebase console, click the Android icon.

Docusaurus logo

  1. Enter Package Name (e.g., com.example.userApp) and click on register app.

Docusaurus logo

  1. After registering the app, you will receive the Google JSON file, download it and save it to the android/app/ folder. Otherwise you can download later after add SHA fingerprint in firebase project so google login will work with your project. Check below how to add SHA in fribase

Docusaurus logo

Set Up Firebase Authentication

  1. Go to Build -> Authentication tab and click on Get started.

Docusaurus logo

  1. Then select the Email/Password, Google, Apple, and Phone Number one by one and enable them.

Docusaurus logo

  1. Re-check if all these 3 modes of authentication are enabled or not.

Docusaurus logo

SHA Fingerprint

note

SHA-1 fingerprint is a unique key generated for your PC that can be used for signing. It is important to have in the add Firebase as we are using Google Login and OTP Login, and to authorize these logins, we need a SHA Fingerprint certificate.

Add a SHA fingerprint to Firebase:

  1. Follow these steps if you didn't initially provide a SHA certificate fingerprint for your Firebase Android app or if you need to add an additional one:

    • In your Project settings, go to the Your apps card. and Select the Firebase Android app to which you want to add a SHA fingerprint.

Docusaurus logo

  • Click Add fingerprint.

Docusaurus logo

  • Enter or paste the SHA fingerprint, then click Save.

How to generate the SHA from Android Studio

note

There are two types of SHA Fingerprint, Release SHA Fingerprint, and Debug SHA Fingerprint. Here we will see how to generate both types of SHA Fingerprint.

  1. Create a file in android folder of your project name key.properties if not exists.

  2. Add properties and it's value below

       storePassword=<Your JKS password>
    keyPassword=<Your JKS Key Password>
    keyAlias=<You JKS Key Alias>
    storeFile=<Your jks file location path>
  3. Add following line to your Android/app/build.gradle file above the all android block (Check if this line already exist or not)

       def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists())
    {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
  4. Now in app:build.gradle android block check for below lines if not exist Add into your Android/app/build.gradle

       signingConfigs {
    release {
    keyAlias keystoreProperties['keyAlias']
    keyPassword keystoreProperties['keyPassword']
    storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
    storePassword keystoreProperties['storePassword']
    }
    }

    buildTypes {
    release {
    signingConfig signingConfigs.release
    }
    }
  5. Open your terminal and enter following command

       cd android
          ./gradlew signinReport

Wait for a while it will generate your SHA Copy Both SHA1 and SHA256 for variant & config Debug and Release and add to Firebase

Docusaurus logo

  • Copy SHA1 and SHA256 of both "App signing key certificate" and "Upload key certificate"
  • Paste it to Firebase
Successful !!

Great! You have successfully configured the Android App Firebase for Push Notificationa and Google Social Login!